from config import token
import requests

class ManageInstallRecord(object):
    #添加安装记录
    @classmethod
    def record_add(self,json_data):
        url = "http://kaxiaoli.kalulibattery.com/battery-admin-api/batteryInstallation/add"
        headers = {"x-access-token": token}

        resq = requests.post(url=url, headers=headers, json=json_data)
        return resq.json()

    #分页查询安装记录表
    @classmethod
    def select_install_all(self, json_data):
        url = "http://kaxiaoli.kalulibattery.com/battery-admin-api/batteryInstallation/page/query"
        headers = {"x-access-token": token}
        resq = requests.post(url=url, headers=headers, json=json_data)
        return resq.json()

    # id删除
    @classmethod
    def delete_install_uid(self, id):
        url = f"http://kaxiaoli.kalulibattery.com/battery-admin-api/batteryInstallation/delete/{id}"
        headers = {"x-access-token": token}
        resq = requests.get(url=url, headers=headers)
        return resq.json()
    #修改安装记录表
    @classmethod
    def update_install_record(self,json_data):
        url = f"http://kaxiaoli.kalulibattery.com/battery-admin-api/batteryInstallation/update"
        headers = {"x-access-token": token}
        resq = requests.post(url=url, headers=headers,json=json_data)
        return resq.json()